@import '../buttons';

.button-dropdown {
  position: relative;
  display: inline-block;

  &.open {
    .secondary-items {
      visibility: inherit;
    }
  }

  &.open.open-up {
    .secondary-items {
      border-radius: @border-radius-base @border-radius-base 0 @border-radius-base;
      box-shadow: 0 0.5px 0 @standard-shadow-color, 0 -0.5px 0 @standard-shadow-color,
        0.5px 0 0 @standard-shadow-color, -0.5px 0 0 @standard-shadow-color,
        0 -3px 12px @standard-shadow-color;
      top: -100%;
      transform: translate(0, -6px);
    }
    .secondary-picker {
      border-top-right-radius: 0;
    }
  }
  &.open.open-down {
    .secondary-items {
      border-radius: @border-radius-base 0 @border-radius-base @border-radius-base;
      box-shadow: 0 0.5px 0 @standard-shadow-color, 0 -0.5px 0 @standard-shadow-color,
        0.5px 0 0 @standard-shadow-color, -0.5px 0 0 @standard-shadow-color,
        0 5px 12px @standard-shadow-color;
      transform: translate(0, 1.5px);
    }
    .secondary-picker {
      border-bottom-right-radius: 0;
    }
  }

  &.btn-emphasis {
    .primary-item,
    .secondary-picker,
    .only-item {
      .btn.btn-emphasis();
    }
    .primary-item {
      border-right: 0;
    }
  }

  .primary-item,
  .only-item {
    .btn();
    cursor: default;
    color: @btn-default-text-color;
  }
  .primary-item {
    border-radius: @border-radius-base 0 0 @border-radius-base;
  }

  .secondary-picker {
    .btn();
    box-shadow: @standard-shadow-color 0 0.5px 0, @standard-shadow-color 0 -0.5px 0,
      @standard-shadow-color 0.5px 0 0, @standard-shadow-color 0 0.5px 1px;
    border-radius: 0 @border-radius-base @border-radius-base 0;
    border-left: 0;
    padding: 0 6px;
  }
  .secondary-items {
    &:hover {
      cursor: default;
    }
    &.left {
      width: auto;
      left: -1px;
      right: auto;
      white-space: nowrap;
    }
    z-index: 3;
    background-color: @background-secondary;
    position: absolute;
    right: 0;
    white-space: nowrap;
    visibility: hidden;

    .menu {
      .footer-container,
      .header-container {
        display: none;
      }
      .content-container {
        background: transparent;
        margin-top: 0;
      }
      .item {
        font-size: 13px;
        padding: 4px 11px;
        &:first-child {
          padding-top: 6px;
        }
        &:last-child {
          padding-bottom: 6px;
        }
        img {
          margin-right: 4px;
          vertical-align: text-bottom;
        }
        &.selected {
          background-color: inherit;
          color: @text-color;
        }
      }
      .item:first-child {
        border-top-left-radius: @border-radius-base;
      }
      .item:last-child {
        border-bottom-left-radius: @border-radius-base;
        border-bottom-right-radius: @border-radius-base;
      }
      .item:hover {
        background-color: darken(@background-secondary, 3%);
        color: inherit;
      }
    }
  }
  img {
    background-color: @text-color;
  }
}

body.platform-win32 {
  .button-dropdown {
    .primary-item {
      .windows-btn-bg;
      .windows-btn-border;
      border-radius: 0;
      position: relative;
      left: -1px;
    }
    .secondary-picker {
      .windows-btn-bg;
      .windows-btn-border;
      position: relative;
      right: -1px;
    }
    .secondary-picker,
    .secondary-items {
      border-radius: 0;
    }
    &.btn-emphasis {
      .primary-item,
      .secondary-picker,
      .only-item {
        border: 0;
        background: @btn-emphasis-bg-color;
        &:hover {
          border-radius: 0;
          background: darken(@btn-emphasis-bg-color, 10%);
        }
        &:active {
          background: @btn-emphasis-bg-color;
        }
      }
      .primary-item {
        box-shadow: -1px 0 0 2px @btn-emphasis-bg-color;
        &:hover {
          box-shadow: -1px 0 0 2px darken(@btn-emphasis-bg-color, 10%);
        }
      }
      .secondary-picker {
        box-shadow: 1px 0 0 2px @btn-emphasis-bg-color;
        &:hover {
          box-shadow: 1px 0 0 2px darken(@btn-emphasis-bg-color, 10%);
        }
      }
      .only-item {
        box-shadow: 0 0 0 2px @btn-emphasis-bg-color;
        &:hover {
          box-shadow: 0 0 0 2px darken(@btn-emphasis-bg-color, 10%);
        }
      }
    }
  }
}
